package com.lg.concurrent.atomic;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * 带while true 的cas
 */
public class AtomicIntegerTest {
    public static void main(String[] args) {
        AtomicInteger atomicInteger = new AtomicInteger(0);
        atomicInteger.set(1);
        atomicInteger.get();
        atomicInteger.compareAndSet(1, 2);
        System.out.println(atomicInteger.incrementAndGet());
        System.out.println(atomicInteger.getAndIncrement());
        System.out.println(atomicInteger.get());

        System.out.println(atomicInteger.decrementAndGet());
        System.out.println(atomicInteger.getAndAdd(2));
    }
}
